//
//  NewHeaderInit.m
//  j绝版新闻客户端
//
//  Created by weige on 16/5/10.
//  Copyright © 2016年 weige. All rights reserved.
//

#import "NewHeaderInit.h"

@implementation NewHeaderInit
{
    NSMutableArray *btns;
    
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        btns=[NSMutableArray arrayWithCapacity:100];
        self.showsHorizontalScrollIndicator=NO;
        self.showsVerticalScrollIndicator=NO;
        self.pagingEnabled=YES;
        self.backgroundColor=[UIColor clearColor];
        self.alpha=.0f;

    }
    return self;
}

-(void)addBtn:(UIButton *)btn
{
    
    NSInteger width=5;
    UIButton *lastButton=[btns lastObject];
    if (lastButton) {
        
        width+=lastButton.frame.origin.x+lastButton.frame.size.width;
    }
    else
    {
        width=0;
    }
    CGRect ret=btn.frame;
    ret.origin.x=width;
    btn.frame=ret;
    
    btn.titleLabel.font=[UIFont systemFontOfSize:14.0F];
    
    [btns addObject:btn];

    [self addSubview:btn];
       if (width>self.frame.size.width) {
        
        self.contentSize=CGSizeMake(width+btn.frame.size.width, 44);
    }
    //NSLog(@"%d",btns.count);
    
}

-(void)clearColorBtn
{
    NSLog(@"%lu",(unsigned long)btns.count);
    for(UIButton *btn in btns)
    {
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }
}
@end
